//
//  ViewController.m
//  JavaBaas_iOS_SDK
//
//  Created by zhaopeng on 16/1/21.
//  Copyright © 2016年 Buge. All rights reserved.
//

#import "ViewController.h"
#import "JavaBaas.h"
#import "UserViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
//    JB.init("http://missu.oicp.io/api","5fa9230488cad5998483b0bf","3b7fdf77b4204d648401c388d0e93e1a");
    
    [JBOSCloud setApplicationId:@"5fa9230488cad5998483b0bf" clientKey:@"3b7fdf77b4204d648401c388d0e93e1a" baseUrl:@"http://missu.oicp.io"];
    
    _dataArray = @[@"用户操作",@"文件操作",@"增删改查操作",@"云方法",@"ACL"];
    
//    模糊查询
//    JBQuery *query = [JBQuery queryWithClassName:@"_User"];
//    [query whereKey:@"username" containsString:@"peng"];
//    [query whereKey:@"username" hasPrefix:@"weibo"];
//    [query whereKey:@"username" hasSuffix:@"peng"];
//    [query whereKey:@"nickName" matchesRegex:@"[pP][eE][nN][gG]"];
//    
//    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
//        for (JBObject  *obj in objects) {
//            NSLog(@"%@", [obj objectForKey:@"nickName"]);
//        }
//    }];
    
    
//    JBUser *user = [JBUser objectWithoutDataWithObjectId:@"9b0e6be8efd04ba880a800f19f98d860"];
    
    //模糊不匹配
//    JBQuery *query1 = [JBQuery queryWithClassName:@"_User"];
//    [query1 whereKey:@"nickName" matchesRegex:@"^((?!peng).)*$" modifiers:@"i"];
//    
//    
//    
//    [query1 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
//        for (JBObject *obj in objects) {
//            NSLog(@"%@", [obj objectForKey:@"nickName"]);
//        }
//    }];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CELLID"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CELLID"];
    }
    cell.textLabel.text = _dataArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.row) {
        case 0:
            [self performSegueWithIdentifier:@"User" sender:self];
            break;
        case 1:
            [self performSegueWithIdentifier:@"File" sender:self];
            break;
        case 2:
            [self performSegueWithIdentifier:@"Query" sender:self];
            break;
        case 3:
            [self performSegueWithIdentifier:@"Clound" sender:self];
            break;
        case 4:
            [self performSegueWithIdentifier:@"ACL" sender:self];
            break;
        default:
            break;
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
